import { AxiosRequestConfig } from "axios";
import { mockData } from './mock/data';

interface Response<T> {
    errorCode: number
    errorInfo: string
    errorPath: string
    result: T
}


async function get<T = any, R = Response<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R> {
    const res = {
        errorCode: 200,
        errorInfo: '',
        errorPath: '',
        result: mockData[url]
    }
    return res as R;
}

async function post<T = any, R = Response<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R> {
    return {
        errorCode: 200,
        errorInfo: '',
        errorPath: '',
        result: mockData[url]
    } as R;
}

export default {
    get,
    post
}